package utils

import (
	"fmt"
	"gopkg.in/ini.v1"
)

var (
	AppMode string
	HttpPort string
	JwtKey string

	Db string
	DbHost string
	DbUser string
	DbPort string
	DbPassWord string
    DbName string

	AccessKey   string
	SecretKey   string
	Bucket      string
	QiniuServer string
)




func init(){
	file,err:=ini.Load("config/config.ini")
	if err!=nil{
		fmt.Println("情检查路径是否正确",err)
	}
	LoadServer(file)
	LoadData(file)
	LoadQiniu(file)

}
func LoadServer(file *ini.File){
	AppMode =file.Section("server").Key("AppMode").MustString("debug")
	HttpPort=file.Section("server").Key("HttpPort").MustString(":3000")
	JwtKey=file.Section("server").Key("JwtKey").MustString("89js82js72")

}

func LoadData(file *ini.File){
	Db         =file.Section("database").Key("Db").MustString("mysql")
	DbHost     =file.Section("database").Key("DbHost").MustString("localhost")
	DbPort     =file.Section("database").Key("DbPort").MustString("3306")
	DbUser     =file.Section("database").Key("DbUser").MustString("root")
	DbPassWord =file.Section("database").Key("DbPassWord").MustString("wa6.")
	DbName     =file.Section("database").Key("DbName").MustString("ginblog")
}

func LoadQiniu(file *ini.File){
	AccessKey=file.Section("qiniu").Key("AccessKey").String()
	SecretKey=file.Section("qiniu").Key("SecretKey").String()
	Bucket=file.Section("qiniu").Key("Bucket").String()
	QiniuServer=file.Section("qiniu").Key("QiniuServer").String()
}
